home *** CD-ROM | disk | FTP | other *** search
- ; NAME dec_bin_su
- ; PURPOSE converts the decimal number1 to a binary bit pattern in text1 suppressing
- ; leading zeros
- ; DESIGN
- ; load number1
- ; start <- false
- ; for i <- 31 down to 0
- ; asl number1
- ; if carry = 1
- ; then
- ; character = '1'
- ; start <- true
- ; else
- ; character = '0'
- ; endif
- ; if i = 31
- ; then
- ; start <- true
- ; endif
- ; place character at end of text1
- ; if start
- ; then
- ; increment text pointer
- ; endif
- ; end for
- ; place control character at end of text1
-
- ; NOTE
-
-
- ; r1 stores the address of number to be converted
- ; r4 stores the address of the converted string
-
- ; r6 is loaded with the number to be converted
- ; r7 is used as a loop counter (i)
- ; r8 holds a '1' or '0' depending on the carry flag (character)
- ; r9 is a flag set to 1 when a non zero bit is met (start)
-
- ldr r6, [r1]
- mov r7, #31
- mov r9, #0
- .loop
- movs r6, r6, lsl #1
- movcc r8, #48
- movcs r8, #49
- movcs r9, #1
- cmp r7, #0
- moveq r9, #1
- strb r8, [r4]
- add r4, r4, r9
- subs r7, r7, #1
- bpl loop
- mov r8, #0
- strb r8, [r4]
-
-
-